package com.wufun.overseas.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wufun.overseas.R;
import com.wufun.overseas.models.bean.MySearchDetailBean;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by yangg on 2017/12/2.
 */

public class SearchDetailAdapter extends BaseAdapter {
    Context mContext;
//    MySearchDetailBean lists;
    List<MySearchDetailBean.DataBean.ResBean>  list=new ArrayList<>();
    public SearchDetailAdapter(Context context, List<MySearchDetailBean.DataBean.ResBean>  list) {
        this.mContext = context;
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView==null){
            viewHolder=new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.searchdetailadapter_item, null);
           viewHolder.tv_title= (TextView) convertView.findViewById(R.id.search_adapter_tv_title);
           viewHolder.tv_content= (TextView) convertView.findViewById(R.id.search_adapter_tv_content);
           viewHolder.tv_opensize= (TextView) convertView.findViewById(R.id.search_adapter_tv_openSize);
           viewHolder.tv_revet= (TextView) convertView.findViewById(R.id.search_adapter_tvrevert);
           viewHolder.tv_like= (TextView) convertView.findViewById(R.id.search_adapter_tv_up_like);
           convertView.setTag(viewHolder);
        }else{
           viewHolder= (ViewHolder) convertView.getTag();
        }

         viewHolder.tv_title.setText(list.get(position).getSubject());
         viewHolder.tv_content.setText(list.get(position).getMessage());
         viewHolder.tv_opensize.setText(list.get(position).getView());
         viewHolder.tv_revet.setText(list.get(position).getComment());
         viewHolder.tv_like.setText(list.get(position).getPraise());

        return convertView;
    }

    class  ViewHolder{
         TextView tv_title,tv_content,tv_opensize,tv_revet,tv_like;

    }
}
